/*
 * @Author: your name
 * @Date: 2021-05-31 14:17:57
 * @LastEditTime: 2021-06-07 15:05:53
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \egg-demo\app\schema\goods.js
 */

'use strict';

// const uuidv1 = require('uuid/v1');
// import { v4 as uuidv4 } from 'uuid';

module.exports = app => {
  const { Sequelize } = app;
  const { STRING, BIGINT, DATE, ENUM, Op, UUIDV4, UUID } = Sequelize;

  return {
    uuid: {
        type: STRING(38),
        allowNull: false,
        primaryKey: true,
        defaultValue: UUIDV4,
      },
      created_at: DATE,
      updated_at: DATE,
      created_use_uuid: {
        type: UUID,
        allowNull: true,
        references: {
          model: 'users',
          key: 'uuid',
        },
        onUpdate: 'cascade',
        onDelete: 'cascade',
      },
      name: {
        type: STRING(128),
        allowNull: false,
        comment: "商品品类名",
      },
      intro: {
        type: STRING(255),
        allowNull: true,
        comment: "商品品类介绍",
      },
      deleted: {
        type: ENUM('0', '1'),
        allowNull: false,
      }
  }
}
